import utils from '@/common/check.js'
import preutils from '@/common/preutils.js'
export default {
	getUploadLevelBtnShow(rows) {
		let level = uni.getStorageSync(preutils.accountLevel);
		if (level == 2) {
			return 2;
		} else if (level == 1) {
			return 1;
		} else {
			return 0;
		}
	},

	getSelect(rows) {
		let level = uni.getStorageSync(preutils.accountLevel);
		if (level == 2) {
			return this.getSelectP2(rows);
		} else {
			return this.getSelectP1(rows);
		}
	},
	getSelectP1(rows) {
		// 运单状态:0=未经过一级网点,300=待装车,400=已发车,500=已到达,600=已分拨,700=已签收
		if (rows.status == 300) {
			return true;
		} else {
			return false;
		}
	},
	getSelectP2(rows) {
		// 二级网点订单状态:0=未经过二级网点,100=二级网点待装车（二级网点已开单）,200=二级网点已发出,
		// 300=已到达一级网点（二级网点已开单）,400=一级网点已发出,500=分拨中心已到达,600=分拨中心已分拨,700=已签收
		if (rows.status_p2 == 100) {
			return true;
		} else {
			return false;
		}
	},

	status(rows) {
		let level = uni.getStorageSync(preutils.accountLevel);
		if (level == 2) {
			return this.getStatusP2Str(rows);
		} else if (level == 1) {
			return this.getStatusP1Str(rows);
		} else {
			return this.getStatusStr(rows);
		}
	},

	getStatusStr(rows) {
		// 运单状态:0=未经过一级网点,300=待装车,400=已发车,500=已到达,600=已分拨,700=已签收
		let str = "";
		switch (rows.status) {
			case 0:
				str = "无";
				break;
			case 300:
				str = "一级网点待装车";
				break;
			case 400:
				str = "一级网点已发车";
				break;
			case 500:
				str = "已到达分拨中心";
				break;
			case 600:
				str = "分拨中心已分拨";
				break;
			case 650:
				str = "到达末端网点";
				break;
			case 700:
				str = "已签收";
				break;
		}
		// str = str +'-p1-'+ rows.status;
		if (rows.status == 0) {
			str = this.getStatusP2(rows)
		}

		return str;
	},
	getStatusP1Str(rows) {
		// 运单状态:0=未经过一级网点,300=待装车,400=已发车,500=已到达,600=已分拨,700=已签收
		let str = "";
		switch (rows.status) {
			case 0:
				str = "无";
				break;
			case 300:
				str = "待装车";
				break;
			case 400:
				str = "已发车";
				break;
			case 500:
				str = "已到达分拨中心";
				break;
			case 600:
				str = "分拨中心已分拨";
				break;
			case 650:
				str = "到达末端网点";
				break;
			case 700:
				str = "已签收";
				break;
		}
		// str = str + "-p1-" + rows.status;
		return str;
	},
	getStatusP2Str(rows) {
		// 二级网点订单状态:0=未经过二级网点,100=二级网点待装车（二级网点已开单）,200=二级网点已发出,
		// 300=已到达一级网点（二级网点已开单）,400=一级网点已发出,500=分拨中心已到达,600=分拨中心已分拨,700=已签收
		let str = "";
		switch (rows.status_p2) {
			case 0:
				str = "未经过二级网点";
				break;
			case 100:
				str = "待装车";
				break;
			case 200:
				str = "已发出";
				break;
			case 300:
				str = "已到达一级网点";
				break;
			case 400:
				str = "一级网点已发出";
				break;
			case 500:
				str = "分拨中心已到达";
				break;
			case 600:
				str = "分拨中心已分拨";
				break;
			case 650:
				str = "到达末端网点";
				break;
			case 700:
				str = "已签收";
				break;
		}
		// str = str + "-p2-" + rows.status_p2;
		return str;
	},
	getStatusP2(rows) {
		// 二级网点订单状态:0=未经过二级网点,100=二级网点待装车（二级网点已开单）,200=二级网点已发出,
		// 300=已到达一级网点（二级网点已开单）,400=一级网点已发出,500=分拨中心已到达,600=分拨中心已分拨,700=已签收
		let str = "";
		if (rows.start_point_level == 1) {
			str = "无";
		} else {
			switch (rows.status_p2) {
				case 0:
					str = "无";
					break;
				case 100:
					str = "二级网点待装车";
					break;
				case 200:
					str = "二级网点已发出";
					break;
				case 300:
					str = "已到达一级网点";
					break;
				case 400:
					str = "一级网点已发出";
					break;
				case 500:
					str = "分拨中心已到达";
					break;
				case 600:
					str = "分拨中心已分拨";
					break;
				case 650:
					str = "到达末端网点";
					break;
				case 700:
					str = "已签收";
					break;
			}
		}

		// str = str + "-p2-" + rows.status_p2;
		return str;
	},

	getLevel(rows) {
		let str = "";
		let level = uni.getStorageSync(preutils.accountLevel);
		switch (level) {
			case 2: {
				str = "自开";
				break;
			}
			case 1: {
				switch (rows.start_point_level) {
					case 2:
						str = rows.start_point_name;
						break;
					case 1:
						str = "自开";
						break;
					default:
						str = "";
						break;
				}
				break;
			}
			default:
				switch (rows.start_point_level) {
					case 2:
						str = "下级";
						break;
					case 1:
						str = "下级";
						break;
					default:
						str = "";
						break;
				}
				break;
		}

		return str;
	},

	getStatus(rows) {
		let str = "";
		switch (rows.status) {
			case 500:
				str = "发";
				break;
			case 600:
				str = "到";
				break;
		}
		return str;
	},

	getTransitStatus(rows) {
		let str = "";
		switch (rows.transit_status) {
			case 1:
				str = "未中转";
				break;
			case 2:
				str = "已中转";
				break;
		}
		return str;
	},
	getDestinationCity(rows) {
		let city = utils.strNullReplace(rows.to_city, "");
		let county = utils.strNullReplace(rows.to_county, "");
		return city + "" + county;
	},

	getDisabledEdit(rows) {
		let level = uni.getStorageSync(preutils.accountLevel);
		if (level == 2) {
			if (rows.status_p2 >= 300) {
				return true;
			} else {
				return false;
			}
		} else if (level == 1) {
			if (rows.start_point_level == 2) {
				return true;
			} else {
				if (rows.status >= 400) {
					return true;
				} else {
					return false;
				}
			}
		} else {
			return true;
		}
	},
	getOrderAmountPay(rows) {
		let str = "";
		switch (rows.order_amount_pay) {
			case 10:
				str = "现付";
				break;
			case 20:
				str = "提付";
				break;
			case 30:
				str = "回单付";
				break;
			case 40:
				str = "月结";
				break;
			case 50:
				str = "扣付";
				break;
		}
		return str;
	},
	getReceiptType(rows) {
		let str = "";
		switch (rows.receipt_type) {
			case 1:
				str = "托运单签名盖章返回";
				break;
			case 2:
				str = "送货单签名盖章返回";
				break;
			case 3:
				str = "回单签名盖章返回";
				break;
			case 4:
				str = "其他";
				break;
			case 5:
				str = "收条";
				break;
		}
		return str;
	},

	getIsUrgency(rows) {
		if (rows.is_urgency == 1) {
			return '否';
		} else {
			return '是';
		}
	},
	getIsControl(rows) {
		if (rows.is_control == 1) {
			return '否';
		} else {
			return '是';
		}
	},
	getIsUnusual(rows) {
		if (rows.is_unusual == 1) {
			return '否';
		} else {
			return '是';
		}
	},

	getDepartPic2(rows) { //二级发车
		if (utils.isNull(rows, 'obj')) {
			return ""
		}
		if (utils.isNull(rows.waybill_certificate.depart_certificate_p2, "")) {
			return '无'
		} else {
			return '有'
		}
	},

	getArrivePic1(rows) { //一级到车
		if (utils.isNull(rows, 'obj')) {
			return ""
		}
		if (utils.isNull(rows.waybill_certificate.delivery_certificate_p1, "")) {
			return '无'
		} else {
			return '有'
		}
	},

	getDepartPic1(rows) { //一级发车
		if(utils.isNull(rows,'obj')){
			return ""
		}
		if (utils.isNull(rows.waybill_certificate.depart_certificate_p1, "")) {
			return '无'
		} else {
			return '有'
		}
	},


	getAllocatePic1(rows) { //分拨中心到车
		if(utils.isNull(rows,'obj')){
			return ""
		}
		if (utils.isNull(rows.waybill_certificate.delivery_certificate, "")) {
			return '无'
		} else {
			return '有'
		}
	},
	getAllocatePic2(rows) { //分拨中心分拨
		if(utils.isNull(rows,'obj')){
			return ""
		}
		if (utils.isNull(rows.waybill_certificate.depart_certificate, "")) {
			return '无'
		} else {
			return '有'
		}
	},


	getDepartPic2List(rows) { //二级发车
		var list = [];
		if (utils.isNull(rows, 'obj')) {
			return list
		}
		if (!utils.isNull(rows.waybill_certificate.depart_certificate_p2, "")) {
			list = rows.waybill_certificate.depart_certificate_p2.split(',');
		}
		return list;
	},
	getArrivePic1List(rows) { //一级到车
		var list = [];
		if (utils.isNull(rows, 'obj')) {
			return list
		}
		if (!utils.isNull(rows.waybill_certificate.delivery_certificate_p1, "")) {
			list = rows.waybill_certificate.delivery_certificate_p1.split(',');
		}
		return list;
	},
	getDepartPic1List(rows) { //一级发车
		var list = [];
		if (utils.isNull(rows, 'obj')) {
			return list
		}
		if (!utils.isNull(rows.waybill_certificate.depart_certificate_p1, "")) {
			list = rows.waybill_certificate.depart_certificate_p1.split(',');
		}
		return list;
	},


	getAllocatePic1List(rows) { //分拨中心到车 
		var list = [];
		if (utils.isNull(rows, 'obj')) {
			return list
		}
		if (!utils.isNull(rows.waybill_certificate.delivery_certificate, "")) {
			list = rows.waybill_certificate.delivery_certificate.split(',');
		}
		return list;
	},
	getAllocatePic2List(rows) { //分拨中心分拨 
		var list = [];
		if (utils.isNull(rows, 'obj')) {
			return list
		}
		if (!utils.isNull(rows.waybill_certificate.depart_certificate, "")) {
			list = rows.waybill_certificate.depart_certificate.split(',');
		}
		return list;
	},
	 
	showDepartBtn(item) { //发货凭证
		let level = uni.getStorageSync(preutils.accountLevel);
		var isUpload = false;
		if(item){
			if (level == 2) {
				if (item.status_p2 == 100) {
					isUpload = true;
				} else {
					isUpload = false;
				}
			} else if (level == 1) {
				if (item.status == 300) {
					isUpload = true;
				} else {
					isUpload = false;
				}
			} else { 
				isUpload = false;
			}
		}
		return isUpload;
	},
	showDeliveryBtn(item) { //到货凭证
		let level = uni.getStorageSync(preutils.accountLevel);
		var isUpload = false;
		if(item){
			if (level == 2) {
				isUpload = false;
			}else if (level == 1) {
				if (item.status_p2 == 200) {
					isUpload = true;
				} else {
					isUpload = false;
				}
			} else {
				if (item.status == 400) {
					isUpload = true;
				} else {
					isUpload = false;
				}
			}
		} 
		return isUpload;
	},
	showAllocationBtn(item) { //分拨凭证
		let level = uni.getStorageSync(preutils.accountLevel);
		var isUpload = false;
		if(item){
			if (level == 2) {
				isUpload = false;
			} else if (level == 1) {
				isUpload = false;
			} else {
				if (item.status == 500) {
					isUpload = true;
				} else {
					isUpload = false;
				}
			}
		}
		
		return isUpload;
	},
};